//
//  SmallDecisionsHqViewController.m
//  SmallDecisions
//
//  Created by 李付雄 on 2025/7/25.
//

#import "SmallDecisionsHqViewController.h"
#import "SmallDecisionsHqView.h"

@interface SmallDecisionsHqViewController ()
@property (nonatomic,strong)SmallDecisionsHqView *hqView;
@property(nonatomic,strong)UIButton *startBtn;
@property(nonatomic,assign)BOOL isSure;

@end

@implementation SmallDecisionsHqViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"划拳";
    [self hqView];
    [self startBtn];
}

- (SmallDecisionsHqView *)hqView {
    if(!_hqView) {
        _hqView = [[SmallDecisionsHqView alloc] init];
        [self.view addSubview:_hqView];
        [_hqView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.mas_offset(0);
            make.centerY.mas_offset(-60);
            make.width.height.mas_offset(240);
        }];
    }
    return _hqView;
}

- (UIButton *)startBtn {
    if(!_startBtn) {
        _startBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_startBtn setTitle:@"出拳" forState:UIControlStateNormal];
        [_startBtn setTitleColor:SmallDecisionsThemeFontColor forState:UIControlStateNormal];
        [_startBtn setTitleColor:[UIColor clearColor] forState:UIControlStateHighlighted];
        _startBtn.titleLabel.font = SmallDecisionsSetBoldFontSize(20);
        _startBtn.layer.cornerRadius = 30;
        _startBtn.layer.masksToBounds = YES;
        _startBtn.backgroundColor = SmallDecisionsThemeColor;
        [_startBtn addTarget:self action:@selector(startBtnAction) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:_startBtn];
        [_startBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(60);
            make.width.mas_offset(260);
            make.centerX.mas_offset(0);
            make.top.equalTo(self.hqView.mas_bottom).offset(60);
        }];
    }
    return _startBtn;
}

- (void)startBtnAction {
    if(self.isSure) {
        [self.hqView startAnimating];
        self.isSure = NO;
        [self.startBtn setTitle:@"出拳" forState:UIControlStateNormal];
    } else {
        [self.hqView stopAnimating];
        self.isSure = YES;
        [self.startBtn setTitle:@"再来一次" forState:UIControlStateNormal];
    }
    
}

@end
